//board.h

#include <wx/wx.h>
#include "gaucho.h"
#include "gauchod1.h"
#include "gauchod2.h"
#include "gauchod3.h"
#include "storkeTower.h"
#include "resources.h"

//This struct stores an x,y pair location and a boolean saying whether that particular x,y location contains an object or not.
struct forboard{
  pair point;
  bool full;
  int type; //this will be 0 for gaucho, 1 for enemy or 2 for neither
};

class board : public wxPanel
{
 public:
  //This is the object's constructor, which initializes all of its member variables and sets up all the event handlers.
  board(wxFrame *parent);

  //This function sets the isStarted variable to true and starts our timer.
  void Start();

  //This function stops the timer and redraws the board.
  void Pause();

  void setTurnongaucho(bool x);

  //This function kills the enemies, when the enemies are in range of the gaucho  
  void Kill();

  //This function calls the parent's (simple's) wxStatusBar and shows the number of lives Storke Tower has
  void showStLives();

  //This function calls the parent's (simple's) wxStatusBar and shows the number of resources the player has
  void showResources();

 protected:
  //This function is called every time the timer goes off, and it calls DrawSquare to draw all the objects currently initialized on the board.
  void OnPaint(wxPaintEvent& event);

  //This function is called every time the timer goes off and it calls Invade() to move all the current enemies on the board to a new location and then calls Refresh() to redraw them in their new location.
  void OnTimer(wxCommandEvent& event);

  //This function is called every time the user clicks on the board. It then initializes a new gaucho object and places it at the location the user clicked on. 
  void OnLeftClick(wxMouseEvent& event);

 private:
  //This specifies a specific width and height for the board object. 
  enum { BoardWidth = 21, BoardHeight = 21, enemyarraysize = 11, gauchoarraysize = 4};

  //This array stores all of the locations on the board and whether or not they have an object in them. 
  forboard fakeboard[21][21]; 

  //This is a pointer to a resources object, that keeps track of how many resources the player has.
  resources* beer;

  int bigcounter; //to count the number of times we reach a y-coord of 20 for the enemies snaking around the board (fakeboard)
 
  //This is a trigger that is turned on when the start button is pressed to prevent the user from placing gauchos before they start the game.
  bool turnongaucho;
 
  storkeTower* st; //This is a pointer to a storkeTower object.
  
  //This function returns the width.
  int SquareWidth() { return GetClientSize().GetWidth() / BoardWidth; }
  
  //This function returns the height.
  int SquareHeight() { return GetClientSize().GetHeight() / BoardHeight; }

  //This function draws a square on the board at location x,y with a specific color.
  void DrawSquare(wxPaintDC &dc, int x, int y, int color);

  //This function determines where an enemy will move next based on its current position on the board.
  void Invade();


  gaucho* gauchoarray[gauchoarraysize]; //This is a pointer to an array of gauchos, whose size is set by the enum 'gauchoarraysize'

  enemy* enemyarray[enemyarraysize]; //This is a pointer to an array of enemy objects.

  wxTimer *timer; //This is a pointer to a timer object.
  bool isStarted; //This is a boolean that stores whether or not the timer has been started.
  bool isPaused; //This is a boolean that stores whether or not the timer has been paused.
  wxStatusBar *m_stsbar; //This is a pointer to a status bar object.

  //This function checks to see if an enemy object is in the same position as the storkeTower object. If it is, it return true. Else it returns false.
  bool checkPosition(enemy* badguy);

  //This function checks to see if we can shoot an enemy and then shoots accordingly
  bool canShoot(enemy* badguy, gaucho* goodguy);

  

};
